package com.bwie.controller;

import com.bwie.pojo.TbUser;
import com.bwie.service.TbUserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginVo;
import com.bwie.vo.SendCodeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * description:
 *
 * @Author zhaohaoyang
 * @Create 2025/7/15 9:21
 * @Version 1.0
 */
@RestController
@RequestMapping("/user/index")
public class IndexController {

    @Autowired
    TbUserService tbUserService;

    /**
     * 登录
     * @param loginVo
     * @return
     */
    @PostMapping("/login")
    public R login(@RequestBody LoginVo loginVo){
        return tbUserService.login(loginVo);
    }

    /**
     * 发送短信验证码
     * @param userMobile
     * @return
     */
    @PostMapping("/sendCode/{userMobile}")
    public R sendCode(@PathVariable("userMobile")String userMobile){
        return tbUserService.sendCode(userMobile);
    }

    /**
     * 校验验证码
     * @param userMobile
     * @param code
     * @return
     */
    @PostMapping("/checkCode/{userMobile}/{code}")
    public R checkCode(@PathVariable("userMobile")String userMobile,@PathVariable("code")String code){
        return tbUserService.checkCode(userMobile,code);
    }

    /**
     * 注册用户
     * @param tbUser
     * @return
     */
    @PostMapping("/regLogin")
    public R regLogin(@RequestBody TbUser tbUser){
        return tbUserService.regLogin(tbUser);
    }


    /**
     * 修改密码
     * @param tbUser
     * @return
     */
    @PostMapping("/updatePass")
    public R updatePass(@RequestBody TbUser tbUser){
        return tbUserService.updatePass(tbUser);
    }
}
